import { request } from '@/utils';
import { getRestBaseUrl, getEcpQueryBaseUrl, getIopDataBaseUrl } from '@/config';

// 查询
export const loadGoodsList = goodsQueryForm =>
  request({
    url: `${getIopDataBaseUrl()}/iop-data/goodsService/list`,
    method: 'POST',
    data: { goodsQueryForm },
    timeout: 3 * 60 * 1000,
  });

// 根据三方店铺名称查询店铺信息
export const loadListStore = (topChannelCode, storeNames) =>
  request({
    url: `${getIopDataBaseUrl()}/iop-data/channelService/list`,
    method: 'POST',
    data: { topChannelCode, storeNames },
    timeout: 3 * 60 * 1000,
  });

// 查询所有蜂窝
export const loadListCellular = () =>
  request({
    url: `${getRestBaseUrl()}/iop/cellularService/listAll`,
    method: 'POST',
    data: null,
    timeout: 3 * 60 * 1000,
  });

// 条件查询符合条件渠道
export const queryChannel = (channelCodes = null, storeLevel = null, storeType = null, cellularCode = null) =>
  request({
    url: `${getRestBaseUrl()}/iop/channelStoreService/listChannel`,
    method: 'POST',
    data: { storeLevel, storeType, cellularCode, channelCodes },
    timeout: 3 * 60 * 1000,
  });

// 查询商品是否限购
export const listLimit = (channelCode = null, goodsCodes = null) =>
  request({
    url: `${getRestBaseUrl()}/iop/taskService/listLimit`,
    method: 'POST',
    data: { channelCode, goodsCodes },
    timeout: 3 * 60 * 1000,
  });

// 条件商品成本价
export const listCostPriceGoods = (channelCode = null, goodsCodes = []) =>
  request({
    url: `${getEcpQueryBaseUrl()}query/GoodsQueryService/listCostPriceGoods`,
    method: 'POST',
    data: { channelCode, goodsCodes },
    timeout: 3 * 60 * 1000,
  });

// 根据蜂窝编码获取竞对门店名称
export const loadCompeteStoreNames = (cellularCode = '') =>
  request({
    url: `${getRestBaseUrl()}/iop/cellularService/listCompeteStoreNames`,
    method: 'POST',
    data: { cellularCode },
    timeout: 3 * 60 * 1000,
  });

// 添加分时段调价任务
export const addTimeTasksApi = data =>
  request({
    url: `${getRestBaseUrl()}/iop/timeTaskService/batchSave`,
    method: 'POST',
    data,
    timeout: 3 * 60 * 1000,
  });
